package com.sunyur.tailor.channel.service.middle.workflow.impl;

import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSONObject;
import com.sunyur.tailor.channel.common.inner.base.MsgResultCode;
import com.sunyur.tailor.channel.common.middle.base.ChannelListResult;
import com.sunyur.tailor.channel.common.middle.base.ChannelResult;
import com.sunyur.tailor.channel.common.middle.util.ChannelResultUtil;
import com.sunyur.tailor.channel.service.inner.purchase.model.PurchaserApplyHeadModel;
import com.sunyur.tailor.channel.service.inner.purchase.model.PurchaserApplyItemModel;
import com.sunyur.tailor.channel.service.inner.purchase.param.PurchaseApplyHeadByCodeParam;
import com.sunyur.tailor.channel.service.inner.purchase.param.PurchaseApplyItemsByCodeParam;
import com.sunyur.tailor.channel.service.inner.purchase.service.SunyurPurchaseApplyService;
import com.sunyur.tailor.channel.service.middle.workflow.MiddleWorkFlowService;
import com.sunyur.tailor.channel.service.outer.keep.param.FeishuForApprovalFormParam;
import com.sunyur.tailor.channel.service.outer.keep.param.SRMPurchaseFeishuForApprovalParam;
import com.sunyur.tailor.channel.service.outer.keep.service.KeepToFeishuService;

import com.sunyur.tailor.channel.service.outer.keep.service.WorkflowBusinessStrategyService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * @Description 外部审批业务接口实现
 * @Author XuHui
 * @Date 2021/7/7 14:37
 * @Version 1.0
 */
@Service("middleWorkFlowService")
@Slf4j
public class MiddleWorkFlowServiceImpl implements MiddleWorkFlowService {

    private static final Logger LOGGER_INFO = LoggerFactory.getLogger(MiddleWorkFlowServiceImpl.class);
    private static final Logger LOGGER_ERROR = LoggerFactory.getLogger(MiddleWorkFlowServiceImpl.class);

    @Autowired
    private ApplicationContext applicationContext;

    @Override
    public ChannelResult<Boolean> start(MsgResultCode msgResultCode) {
        log.info("msgResultCode:{}", JSONObject.toJSONString(msgResultCode));
        WorkflowBusinessStrategyService strategy = applicationContext.getBean(msgResultCode.getWorkflowBusiness(), WorkflowBusinessStrategyService.class);
        return strategy.start(msgResultCode);
    }


    @Override
    public ChannelResult<Boolean> cancel(MsgResultCode msgResultCode) {
        //业务处理
        return ChannelResultUtil.success(true);
    }
}
